﻿CREATE PROCEDURE [dbo].[GetTimeEntriesForApproval]
@managerUserID INT, @projectID INT, @StartDate DATETIME, @EndDate DATETIME
AS
SELECT 
			EntryLogID, 
			EntryLog.Description, 
			Duration,
			OvernightStay,
			EntryDate, 
			EntryLog.ProjectID AS ProjectID, 
			EntryLog.CategoryID AS CategoryID, 
			Categories.Name AS CategoryName, 
			Projects.Name AS ProjectName,
			ManagerUserID, 
			HasBeenBilled,
			Categories.Abbreviation AS CatShortName
		FROM 
			EntryLog 
				INNER JOIN 
				  Categories 
				ON 
				  EntryLog.CategoryID = Categories.CategoryID 
				INNER JOIN 
				  Projects 
				ON 
				  EntryLog.ProjectID = Projects.ProjectID	
		WHERE 
			EntryDate BETWEEN @StartDate AND @EndDate
			AND ManagerUserID = @managerUserID
			AND Projects.ProjectID = @projectID
			order by EntryDate asc

